<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/9
 * Time: 13:24
 */

echo "<title>6-7 PHP中循环结构之while循环语句</title>";
echo "<p style='text-align: center'><a href=\"index.php\"><font size=\"4\">目录</font></a></p>";
header("Content-type: text/html; charset=utf-8");
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";

$sum = 12;//小宠物当前的饥饿程度
echo "我饿啦:(";
echo "<br />";
while($sum<100){//小宠物的饥饿程度达到100，表示小宠物吃饱啦，不用继续喂了，没吃饱继续喂食
    $num = mt_rand(1,20);//数据数，模拟喂食小宠物的小面包
    $sum = $sum + $num;//小宠物吃小面包
    echo "我还没有吃饱！";
    echo "<br />";
}
echo "终于吃饱啦！";

